package tools;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;

import domain.Student;

public class FileTool {
	private static Vector<Student> Data=new Vector<>();
	
	static {	
		//静态代码块从txt中取出数据
		BufferedReader br=null;
		try {
			br=new BufferedReader(new FileReader("src\\msg\\List.txt"));
			String str;
			while((str=br.readLine())!=null) {
				if(str.equals(""))continue;
				String id=str.split(",")[0];
				String name=str.split(",")[1];
				String course=str.split(",")[2];
				String classes=str.split(",")[3];
				String score=str.split(",")[4];			
				Student s=new Student(id,name,course,classes,score);
				Data.add(s);
				}
			
			} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		finally {
			try {
				br.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public static Vector<Student> getData(){
		return Data;
	}
	public static void addData(Student e){
		Data.add(e);
	}
}
